package com.scott.crm.user.service.impl;

import com.scott.crm.user.bean.UserBean;
import com.scott.crm.user.service.UserService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 黄后林
 * @version 1.0
 * @note
 * @date 2021-12-04 15:05:44
 */
@Service
public class UserServiceImpl implements UserService {

    @Override
    public UserBean login(UserBean userBean) {

        // 模拟从数据库中 根据phone和password查找用户  保存 redis
        UserBean teacher= new UserBean(10010,"13267128038","123456");
        UserBean student= new UserBean(10020,"13112946054","123456");

        List<UserBean> userList = new ArrayList<>();
        userList.add(teacher);
        userList.add(student);

        for(UserBean user: userList){
            if(null == user){
                continue;
            }
            if(user.getPhone().equals(userBean.getPhone()) && user.getPassword().equals(userBean.getPassword())){
                // 如果phone和password匹配成功、说明登录成功
                return user;

            }

        }
        return null;
    }
}
